<?php echo $this->Html->css('web/org_subscription.css'); ?>


<div class="clearfix">
    <div class="text-center wrapper">
        <h2>Review Registration</h2>
        <p>Please review the information provided below and complete your registration</p>
    </div>
    
    <?php 
    $flash = $this->Session->flash();
    
    if( $flash ) {
        echo "<div class='alert alert-danger'>$flash</div>";
    }
    ?>

    <form class='form form-horizontal' method='post' action='<?php echo $this->Html->url(array('action' => 'create')); ?>'>
        <section class="panel">
            <div class="panel-body">
                <div class='well well-sm'>
                    <b>Subscription Type</b>

                    <a href='<?php echo $this->Html->url('/#price'); ?>' class='btn btn-xs btn-info pull-right'><i class='icon icon-edit'></i> Edit</a>
                </div>

                <table class='table table-condensed'>
                    <tr>
                        <td style='width: 180px;'>Subscription Type:</td>
                        <td><?php echo strtoupper($signup_info['SubscriptionType']['name']); ?></td>
                    </tr>
                    <tr>
                        <td>Subscription Cost:</td>
                        <td><?php echo 'GHC ' . strtoupper($signup_info['SubscriptionType']['initial_price']); ?></td>
                    </tr>
                    <tr>
                        <td>Subscription Start:</td>
                        <td><?php echo date('d M Y', strtotime($signup_info['Organisation']['OrganisationSubscription'][0]['subscription_start_dt'])); ?></td>
                    </tr>

                    <tr>
                        <td>Subscription End:</td>
                        <td><?php echo date('d M Y', strtotime($signup_info['Organisation']['OrganisationSubscription'][0]['subscription_end_dt'])); ?></td>
                    </tr>
                </table>

                <div class='well well-sm'>
                    <b>Organisation Info</b>

                    <a href='<?php echo $this->Html->url(array('action' => 'register_info')); ?>' class='btn btn-xs btn-info pull-right'><i class='icon icon-edit'></i> Edit</a>
                </div>

                <table class='table table-condensed'>
                    <tr>
                        <td style='width: 180px;'>Organisation Name:</td>
                        <td><?php echo $signup_info['Organisation']['Organisation']['name']; ?></td>
                    </tr>
                    <tr>
                        <td>Organisation Type:</td>
                        <td><?php echo $signup_info['Organisation']['OrganisationType']['name']; ?></td>
                    </tr>

                    <!--<tr>
                        <td>Primary Account Name:</td>
                        <td><?php //echo $signup_info['Organisation']['OrganisationAccount'][0]['first_name'] . ' ' . $signup_info['Organisation']['OrganisationAccount'][0]['last_name']; ?></td>
                    </tr>

                    <tr>
                        <td>Account Username:</td>
                        <td><?php //echo $signup_info['Organisation']['OrganisationAccount'][0]['username']; ?></td>
                    </tr>-->

                </table>

                <?php if (isset($signup_info['Billing'])) { ?>
                    <div class='well well-sm'>
                        <b>Billing Information</b>

                        <a href='<?php echo $this->Html->url(array('action' => 'register_payments')); ?>' class='btn btn-xs btn-info pull-right'><i class='icon icon-edit'></i> Edit</a>
                    </div>

                    <table class='table table-condensed'>
                        <tr>
                            <td style='width: 180px;'>Billing Name:</td>
                            <td><?php echo $signup_info['Billing']['first_name'] . ' ' . $signup_info['Billing']['last_name']; ?></td>
                        </tr>
                        <tr>
                            <td>Card Number:</td>
                            <td>
                                <?php
                                $card_number = $signup_info['Billing']['card_number'];
                                echo str_replace(substr($card_number, 0, strlen($card_number) - 4), 'VISA-', $card_number);
                                ?>
                            </td>
                        </tr>

                        <tr>
                            <td>Expiry Month / Year:</td>
                            <td><?php echo $signup_info['Billing']['expiry_month'] . ' / ' . $signup_info['Billing']['expiry_year']; ?></td>
                        </tr>

                    </table>
                <?php } ?>

                <table class="table">
                    <tr>
                        <td width="180"></td>
                        <td style='padding-top: 30px'>
                            <label style="font-size: 12px;" >
                                <input type="checkbox" value="1" name="data[agreed_to_terms]" id="agreed_to_terms" />

                                I agree to the "<a id="register_terms" href="<?php echo $this->Html->url(array('action' => 'register_terms')); ?>">Terms & Conditions</a>" for using this service.
                            </label>

                        </td>
                    </tr>
                </table>
            </div>

            <div class='panel-footer' style="overflow: hidden;">
                <div class="col-lg-10 col-lg-offset-2">
                    <button class='btn btn-sm btn-success' type='submit' disabled="" id="complete_register">Complete Registration</button>
                    <a href='<?php echo $this->Html->url(array('action' => 'register_cancel')); ?>' class='btn btn-sm btn-danger btn-cancel'>Cancel</a>
                </div>
            </div>
        </section>
    </form>
    
</div>

<script>
    $(document).ready(function() {
        $("#agreed_to_terms").change(function() {

            if ($(this).is(":checked")) {
                $("#complete_register").removeAttr('disabled');
            }

            else {
                $("#complete_register").attr('disabled', 'disabled');
            }
        });

        $("#register_terms").click(function(e) {
            e.preventDefault();

            $.get($(this).attr('href'), function(html) {
                var dialog = $("<div />").dialog({
                    title: 'Terms And Conditions',
                    width: 700,
                    height: 500,
                    modal: true,
                    buttons: {
                        'Close': function() {
                            dialog.dialog('close');
                        }
                    }
                }).html(html);

            });
        });
    });
</script>